﻿using System;
using System.Collections.Generic;
using Pay.Core;

namespace Pay.Service {
	public class PayResultCode {
		private static object syncRoot = new object();
		private static PayResultCode instance;
		public static PayResultCode Current {
			get {
				if (instance == null) {
					lock (syncRoot) {
						if (instance == null)
							instance = new PayResultCode();
					}
				}
				return instance;
			}
		}

		public string Get(string code, string msg) {
			if (_code.ContainsKey(code)) return _code[code];
			return msg.UnHex();
		}

		private Dictionary<string, string> _code {
			get {
				return new Dictionary<string, string> {
					{"noauth","商户无此接口权限"},{"userpaying","等待付款"},{"notenough","余额不足"},{"orderpaid","商户订单已支付"},
					{"orderClosed","订单已关闭"},{"mchInvalid","非法商户"},{"systemError","系统错误"},{"systemTimeout","系统超时"},
					{"paramError","参数无效"},{"outTradeNoUsed","商户订单号重复"},{"outRefundNoUsed","商户退款单号重复"},{"signError","签名错误"},
					{"postDataEmpty","post数据为空"},{"notUtf8","编码格式错误"},{"payChannelError","付款错误"}
				};
			}
		}
	}
}
